from datetime import datetime

from django.contrib.auth.models import User
from django.db import models


# Create your models here.

'''
    类名代表了数据库表名，且继承了models.Model，类里面的字段代表数据表中的字段,数据类型等等,django可以帮我们自动生成
    每个字段的意思都不做详细解释了
    
'''
# 学历的信息,这里用列表
DEGREE_TYPE=((u'专科', u'专科'), (u'本科', u'本科'), (u'硕士', u'硕士'), (u'博士', u'博士'))

JobTypes = [
    (0,"技术类"),
    (1,"产品类"),
    (2,"运营类"),
    (3,"设计类"),
    (4,"市场营销类")
]

Cities = [
    (0,"北京"),
    (1,"上海"),
    (2,"深圳"),
    (3,"杭州"),
    (4,"广州"),
    (5,"苏州")
]



class Job(models.Model):
    # 定义我们职位的字段
    job_type = models.SmallIntegerField(blank=False, choices=JobTypes, verbose_name=("职位类别"))
    job_name = models.CharField(max_length=250, blank=False, verbose_name=("职位名称"))
    job_city = models.SmallIntegerField(choices=Cities, blank=False, verbose_name=("工作地点"))
    job_responsibility = models.TextField(max_length=1024, verbose_name=("职位职责"))
    job_requirement = models.TextField(max_length=1024,  verbose_name=("职位要求"))
    # blank默认是False，是不允许为空的。
    job_Degree = models.TextField(max_length=1024, blank=True,verbose_name=("学历要求"))
    creator = models.ForeignKey(User, verbose_name=("创建人"), null=True, on_delete=models.SET_NULL)
    # 可以用default 生成时间，也可以用auto_now auto_now_add来
    created_date = models.DateTimeField(verbose_name=("创建日期"),auto_now_add=True)
    modified_date = models.DateTimeField(verbose_name=("修改日期"),auto_now=True)
    class Meta:
        verbose_name = u'招聘管理'  # 对应表在页面上显示的名字
        verbose_name_plural = u'招聘管理'  # 以复数形式
    def __str__(self):
        return str(self.creator)
class Resume(models.Model):
    username = models.CharField(max_length=135, verbose_name=u"姓名")
    applicant = models.ForeignKey(User,verbose_name="申请人",null=True,on_delete=models.SET_NULL)
    city = models.CharField(max_length=135, verbose_name=u"城市")
    phone = models.CharField(max_length=135, verbose_name=u"手机号")
    email = models.EmailField(max_length=135, blank=True, verbose_name="邮箱")
    apply_position = models.CharField(max_length=135, blank=True, verbose_name=u"应聘职位")
    born_address = models.CharField(max_length=135, blank=True, verbose_name=u"生源地")
    gender = models.CharField(max_length=135, blank=True, verbose_name=u"性别")
    # 学校信息
    training_school = models.CharField(max_length=135, blank=True, verbose_name=u"高中学校")
    bachelor_school = models.CharField(max_length=135, blank=True, verbose_name=u"大学学校")
    master_school = models.CharField(max_length=135, blank=True, verbose_name=u"研究生学校")
    doctor_school = models.CharField(max_length=135, blank=True, verbose_name=u"博士生学校")
    major = models.CharField(max_length=135, blank=True, verbose_name=u'专业')
    degree = models.CharField(max_length=135, choices=DEGREE_TYPE, blank=True, verbose_name=u'学历')
    created_date = models.DateTimeField(verbose_name=u'创建时间',default=datetime.now)
    modified_date = models.DateTimeField(verbose_name=u'修改时间',default=datetime.now)
    # 候选人自我介绍，工作经历，项目经历。
    candidate_introduction = models.TextField(max_length=1024,blank=True,verbose_name="自我介绍")
    work_experience = models.TextField(max_length=1024,blank=True,verbose_name="工作经历")
    project_experience = models.TextField(max_length=1024,blank=True,verbose_name="项目经历")
    class Meta:
        verbose_name = '简历'  # 对应表在页面上显示的名字
        verbose_name_plural = u'简历列表'  # 以复数形式